* gun owner
tab V201628

generate gunowner = .
replace gunowner=1 if V201628>=1
replace gunowner=0 if V201628==0
tab gunowner


* Trump voting gun owner
tab V202073

generate trumpgun = .
replace trumpgun=1 if gunowner==1&V202073==2
replace trumpgun=0 if gunowner==1&V202073==1
replace trumpgun=0 if gunowner==1&V202073==3
replace trumpgun=0 if gunowner==1&V202073==4
replace trumpgun=0 if gunowner==1&V202073==5
tab trumpgun



* Trump Voter *

generate trump = .
replace trump=1 if V202073==2
replace trump=0 if V202073==1
replace trump=0 if V202073==3
replace trump=0 if V202073==4
replace trump=0 if V202073==5
tab trump

* Republican gun owner
generate gopgun = .
replace gopgun=1 if gunowner==1&repub==1
replace gopgun=0 if gunowner==0&repub==1
replace gopgun=0 if gunowner==0&repub==0
tab gopgun


* Age (continuous 18-79; 80 = 80 or older)
tab V201507x

generate age = V201507x
replace age=. if age==-9
tab age


* Race
tab V201549x

generate white = .
replace white=1 if V201549x==1
replace white=0 if V201549x==2
replace white=0 if V201549x==3
replace white=0 if V201549x==4
replace white=0 if V201549x==5
replace white=0 if V201549x==6
tab white

* Gender
tab V201600

generate women = .
replace women=1 if V201600==2
replace women=0 if V201600==1
tab women


* Education
tab V201510

generate edu = .
replace edu=1 if V201510==1
replace edu=1 if V201510==2
replace edu=1 if V201510==3
replace edu=2 if V201510==4
replace edu=2 if V201510==5
replace edu=3 if V201510==6
replace edu=4 if V201510==7
replace edu=4 if V201510==8
tab edu


* Party ID
tab V201231x

generate party = .
replace party=1 if V201231x==1
replace party=2 if V201231x==2
replace party=3 if V201231x==3
replace party=4 if V201231x==4
replace party=5 if V201231x==5
replace party=6 if V201231x==6
replace party=7 if V201231x==7
tab party


generate repub = .
replace repub=1 if party==5
replace repub=1 if party==6
replace repub=1 if party==7
replace repub=0 if party==1
replace repub=0 if party==2
replace repub=0 if party==3
replace repub=0 if party==4
tab repub

* Evangelicalism
tab V201459

generate evang = . 
replace evang=1 if V201459==2
replace evang=1 if V201459==3
replace evang=0 if V201459==1
replace evang=0 if V201459==4
tab evang

* Ideology 
tab V201200

generate ideo = .
replace ideo=1 if V201200==1
replace ideo=2 if V201200==2
replace ideo=3 if V201200==3
replace ideo=4 if V201200==4
replace ideo=5 if V201200==5
replace ideo=6 if V201200==6
replace ideo=7 if V201200==7
tab ideo

* Party Strength
gen pstrength = .
replace pstrength = 0 if party == 4
replace pstrength = 1 if party == 3
replace pstrength = 1 if party == 5
replace pstrength = 2 if party == 2
replace pstrength = 2 if party == 6
replace pstrength = 3 if party == 1
replace pstrength = 3 if party == 7
tab pstrength

* Rural
tab V202355

generate rural = .
replace rural=1 if V202355==1
replace rural=1 if V202355==2
replace rural=0 if V202355==3
replace rural=0 if V202355==4
tab rural

* South
tab V203003

generate south = .
replace south=1 if V203003==3
replace south=0 if V203003==1
replace south=0 if V203003==2
replace south=0 if V203003==4
tab south

** IVs **

* Checks and Balances — How important branches of government keep one another from too much power
tab V201367

generate checksbal = .
replace checksbal=1 if V201367==1
replace checksbal=2 if V201367==2
replace checksbal=3 if V201367==3
replace checksbal=4 if V201367==4
replace checksbal=5 if V201367==5
tab checksbal

* Consequences - How important elected officials face serious consequences for misconduct
tab V201368

generate conseq = .
replace conseq=1 if V201368==1
replace conseq=2 if V201368==2
replace conseq=3 if V201368==3
replace conseq=4 if V201368==4
replace conseq=5 if V201368==5
tab conseq

* Basic Facts - "How important is it that people agree on basic facts even if they disagree politically?"
tab V201369

generate facts = .
replace facts=1 if V201369==1
replace facts=2 if V201369==2
replace facts=3 if V201369==3
replace facts=4 if V201369==4
replace facts=5 if V201369==5
tab facts


* Strong President - Helpful or harmful if Pres didn't have to worry about congress/courts (higher = more democratic)
tab V201370

generate strongpres = .
replace strongpres=1 if V201370==1
replace strongpres=2 if V201370==3
replace strongpres=3 if V201370==2
tab strongpres

* Free Press - Favor or oppose restricting journalist access
tab V201373

generate restrictmedia = .
replace restrictmedia=1 if V201373==1
replace restrictmedia=2 if V201373==3
replace restrictmedia=3 if V201373==2
tab restrictmedia


* Investigate Rivals - "In general, how appropriate or inappropriate is it for the president of the United States to ask leaders of foreign countries to investigate political rivals?"
tab V201378

generate rivals = .
replace rivals=1 if V201378==1
replace rivals=1 if V201378==2
replace rivals=2 if V201378==3
replace rivals=3 if V201378==4
replace rivals=3 if V201378==5
tab rivals


* Media Check - HOW CONCERNED GOVERNMENT MIGHT UNDERMINE MEDIA
tab V201376

generate mediacheck = .
replace mediacheck=1 if V201376==1
replace mediacheck=2 if V201376==2
replace mediacheck=3 if V201376==3
replace mediacheck=4 if V201376==4
replace mediacheck=5 if V201376==5
tab mediacheck


* Trust Media
tab V201377

generate trust = .
replace trust=1 if V201377==1
replace trust=2 if V201377==2
replace trust=3 if V201377==3
replace trust=4 if V201377==4
replace trust=5 if V201377==5
tab trust

*** Gun Rights Measures ***

* V202337 - Should fed gov make it easier or more difficult to buy a gun?
tab V202337

generate easygun = .
replace easygun=1 if V202337==2
replace easygun=0 if V202337==1
tab easygun 


* V202338 - How important of an issue is gun access?
tab V202338

generate importantgun = .
replace importantgun=0 if V202338==5
replace importantgun=1 if V202338==4
replace importantgun=2 if V202338==3
replace importantgun=3 if V202338==2
replace importantgun=4 if V202338==1
tab importantgun


* V202339 - Favor or oppose background checks
tab V202339

generate bchecks = .
replace bchecks=0 if V202339==2
replace bchecks=2 if V202339==1
tab bchecks 

* V202342 - Favor or oppose banning assault style weapons
tab V202342

generate banassault = .
replace banassault=0 if V202342==2
replace banassault=2 if V202342==1
tab banassault

* V202345 - Favor or oppose mandatory buy back of assault style weapons
tab V202345

generate buyback = .
replace buyback=0 if V202345==2
replace buyback=2 if V202345==1
tab buyback 

* gun owners * OLS
reg checksbal gunowner age white women edu party evang ideo pstrength rural south
reg conseq gunowner age white women edu party evang ideo pstrength rural south
reg facts gunowner age white women edu party evang ideo pstrength rural south
reg strongpres gunowner age white women edu party evang ideo pstrength rural south
reg rivals gunowner age white women edu party evang ideo pstrength rural south
reg restrictmedia gunowner age white women edu party evang ideo pstrength rural south
reg mediacheck gunowner age white women edu party evang ideo pstrength rural south
reg trust gunowner age white women edu party evang ideo pstrength rural south


* Trump gun owners * OLS
reg checksbal trumpgun age white women edu party evang ideo pstrength rural south
reg conseq trumpgun age white women edu party evang ideo pstrength rural south
reg facts trumpgun age white women edu party evang ideo pstrength rural south
reg strongpres trumpgun age white women edu party evang ideo pstrength rural south
reg rivals trumpgun age white women edu party evang ideo pstrength rural south
reg restrictmedia trumpgun age white women edu party evang ideo pstrength rural south
reg mediacheck trumpgun age white women edu party evang ideo pstrength rural south
reg trust trumpgun age white women edu party evang ideo pstrength rural south

* OLS with Interaction Variables - Republican
reg checksbal gunowner##repub age white women edu evang ideo pstrength rural south
reg conseq gunowner##repub age white women edu evang ideo pstrength rural south
reg facts gunowner##repub age white women edu evang ideo pstrength rural south
reg strongpres gunowner##repub age white women edu evang ideo pstrength rural south
reg rivals gunowner##repub age white women edu evang ideo pstrength rural south
reg restrictmedia gunowner##repub age white women edu evang ideo pstrength rural south
reg mediacheck gunowner##repub age white women edu evang ideo pstrength rural south
reg trust gunowner##repub age white women edu evang ideo pstrength rural south



* OLS with Interaction Variables - Trump Vote
reg checksbal gunowner##trump age white women edu party evang ideo pstrength rural south
reg conseq gunowner##trump age white women edu party evang ideo pstrength rural south
reg facts gunowner##trump age white women edu party evang ideo pstrength rural south
reg strongpres gunowner##trump age white women edu party evang ideo pstrength rural south
reg rivals gunowner##trump age white women edu party evang ideo pstrength rural south
reg restrictmedia gunowner##trump age white women edu party evang ideo pstrength rural south
reg mediacheck gunowner##trump age white women edu party evang ideo pstrength rural south
reg trust gunowner##trump age white women edu party evang ideo pstrength rural south

* OLS Gun Owners X Gun Rights on Democracy Measures
reg checksbal gunowner##easygun age white women edu party evang ideo pstrength rural south
reg conseq gunowner##easygun age white women edu party evang ideo pstrength rural south
reg facts gunowner##easygun age white women edu party evang ideo pstrength rural south
reg strongpres gunowner##easygun age white women edu party evang ideo pstrength rural south
reg rivals gunowner##easygun age white women edu party evang ideo pstrength rural south
reg restrictmedia gunowner##easygun age white women edu party evang ideo pstrength rural south
reg mediacheck gunowner##easygun age white women edu party evang ideo pstrength rural south

*** ROBUSTNESS CHECKS TABLES ***

* Trump gun owners * OLS * Only PartyID
reg strongpres trumpgun age white women edu party evang rural south
reg rivals trumpgun age white women edu party evang rural south
reg restrictmedia trumpgun age white women edu party evang rural south
reg mediacheck trumpgun age white women edu party evang rural south
reg trust trumpgun age white women edu party evang rural south

* OLS with Interaction Variables - Trump Vote * Only Party ID
reg checksbal gunowner##trump age white women edu party evang rural south
reg conseq gunowner##trump age white women edu party evang rural south
reg facts gunowner##trump age white women edu party evang rural south
reg strongpres gunowner##trump age white women edu party evang rural south
reg rivals gunowner##trump age white women edu party evang rural south
reg restrictmedia gunowner##trump age white women edu party evang rural south
reg mediacheck gunowner##trump age white women edu party evang rural south
reg trust gunowner##trump age white women edu party evang rural south

* Trump gun owners * OLS * Only Ideology
reg strongpres trumpgun age white women edu ideo evang rural south
reg rivals trumpgun age white women edu ideo evang rural south
reg restrictmedia trumpgun age white women edu ideo evang rural south
reg mediacheck trumpgun age white women edu ideo evang rural south
reg trust trumpgun age white women edu ideo evang rural south


* OLS with Interaction Variables - Trump Vote * Only Ideology
reg checksbal gunowner##trump age white women edu ideo evang rural south
reg conseq gunowner##trump age white women edu ideo evang rural south
reg facts gunowner##trump age white women edu ideo evang rural south
reg strongpres gunowner##trump age white women edu ideo evang rural south
reg rivals gunowner##trump age white women edu ideo evang rural south
reg restrictmedia gunowner##trump age white women edu ideo evang rural south
reg mediacheck gunowner##trump age white women edu ideo evang rural south
reg trust gunowner##trump age white women edu ideo evang rural south

* Trump gun owners * OLS * Ideo & Party Strength 
reg strongpres trumpgun age white women edu evang ideo pstrength rural south
reg rivals trumpgun age white women edu evang ideo pstrength rural south
reg restrictmedia trumpgun age white women edu evang ideo pstrength rural south
reg mediacheck trumpgun age white women edu evang ideo pstrength rural south
reg trust trumpgun age white women edu evang ideo pstrength rural south

* OLS with Interaction Variables - Trump Vote * Ideology & Party Strength 
reg checksbal gunowner##trump age white women edu evang ideo pstrength rural south
reg conseq gunowner##trump age white women edu evang ideo pstrength rural south
reg facts gunowner##trump age white women edu evang ideo pstrength rural south
reg strongpres gunowner##trump age white women edu evang ideo pstrength rural south
reg rivals gunowner##trump age white women edu evang ideo pstrength rural south
reg restrictmedia gunowner##trump age white women edu evang ideo pstrength rural south
reg mediacheck gunowner##trump age white women edu evang ideo pstrength rural south
reg trust gunowner##trump age white women edu evang ideo pstrength rural south
